# -*- coding:utf-8 -*-
# date: 2018-09-20 11:33
# author: yuan_li
"""

"""
import requests
from bs4 import BeautifulSoup

session = requests.session()

my_cookie = {
    'ASP.NET_SessionId': 'zvohf3bqiexrgsg5q3dwucfj',
    'CNZZDATA1000271341': '134111956-1537409396-http%253A%252F%252Fxsc.cuit.edu.cn%252F%7C1537409396',
    'CenterSoft': 'E9B227F4E6C279506A57E6CD591CACA403C2BCA32BD26F675EAF4AEC2CBCB66C0C9EAD0D3CF190B3E8AF0DF88D4901AD832'
                  'E191071493EAF530FD1EA502C45A00C865CE8D0007A6A4B37B4B4B6DE75B850DB90122AB91AB91552BCABC8A66F427535F70'
                  'E6A2CA8071EB00D991CA778891322BE142EC1FE50227C8762F260911F6F8755975FA5BF0212AA44B7DCA0FCB0E2154A6DB70'
                  '6DDB22F6E4D653802ABEC219C9514022C569225F2FBF49C81925D1AA61F0A9F2752BDD6F69BDB3A7B2FE469D3F229BB9647A'
                  'E9B15195611DBCDB1169115C6013F97B2CA386946',
    'UM_distinctid': '165f50302e096b-01a74dde08e8ed8-1a262c32-1fa400-165f50302e25ca'
}
requests.utils.add_dict_to_cookiejar(session.cookies, my_cookie)


url = 'http://xsc.cuit.edu.cn/Sys/SystemForm/StudentJudge/StuActionInfo.aspx'
data = {
    'YearTime': '2017-2019-0',
    '__VIEWSTATEGENERATOR': "and '1'='1'",
    '__VIEWSTATEENCRYPTED': '',
    'BtnSearch': '查 询'.encode('gbk')
    # '__VIEWSTATE': ''
}

res = session.post(url, data=data)
soup = BeautifulSoup(res.content, 'lxml', from_encoding='gbk')
view_state = soup.find('input', id="__VIEWSTATE")['value']
data['__VIEWSTATE'] = view_state
res = session.post(url, data=data)
soup = BeautifulSoup(res.content, 'lxml', from_encoding='gbk')
print(res.status_code)
for i in soup.find('table', id="GridView1").find_all('tr'):
    print(i.text.strip())

